package url_pattern_util

import (
	"strings"
)

// 转换 URL 模式格式
func ConvertFormat(fullPath string) string {
	if !strings.Contains(fullPath, ":") {
		return fullPath
	}

	parts := strings.Split(fullPath, "/")
	var buffer strings.Builder

	for index := range parts {
		part := parts[index]

		if index != 0 {
			buffer.WriteString("/")
		}

		if strings.HasPrefix(part, ":") {
			buffer.WriteString("{")
			buffer.WriteString(part[1:])
			buffer.WriteString("}")
		} else {
			buffer.WriteString(part)
		}

	}

	return buffer.String()
}
